package cn.cdeden.knowledge.service.impl;

import cn.cdeden.knowledge.domain.dto.SysUserPermissionsDto;
import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.domain.SysUserPermissions;
import cn.cdeden.knowledge.domain.dto.UserAuthorityDto;
import cn.cdeden.knowledge.mapper.SysUserPermissionsMapper;
import cn.cdeden.knowledge.service.SysUserPermissionsService;
import cn.cdeden.knowledge.utils.PageUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysUserPermissionsServiceImpl extends ServiceImpl<SysUserPermissionsMapper, SysUserPermissions> implements SysUserPermissionsService {

    @Override
    public TableDataInfo<UserAuthorityDto> getUserPermissions(Long id, String userName, Long permissionsId, Pageable pageable) {
        IPage<UserAuthorityDto> queryPage = PageUtil.toMybatisPage(pageable);
        IPage<UserAuthorityDto> page = getBaseMapper().getUserPermissions(id, userName, permissionsId, queryPage);
        return TableDataInfo.build(page);
    }

    @Override
    public Boolean updateBatchByScheduleId(Long scheduleId, Long permissionsId, List<Long> userIds) {
        return getBaseMapper().updateBatchByScheduleId(scheduleId, permissionsId, userIds);
    }

    @Override
    public Boolean addByBatch(SysUserPermissionsDto sysUserPermissionsDto) {
        return getBaseMapper().addByBatch(sysUserPermissionsDto);
    }
}
